package com.sansec.demo.interfaces.facade;

import com.sansec.core.utils.IdUtils;
import com.sansec.core.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/nacosCloudConfig")
@RefreshScope
@Slf4j
public class RedisDemoController {
    @Value("${useLocalCache:false}")
    private boolean useLocalCache;

    @Value("${configStr}")
    private String configStr;

    @RequestMapping("/get")
    public boolean get() {
        return useLocalCache;
    }

    @RequestMapping("/getStr")
    public String getStr() {
        return configStr;
    }

    @Autowired
    RedisUtils redisUtils;

    @RequestMapping("/test")
    public String test() {
        redisUtils.set("company","sansec");
        //RedisConfig redisConfig= new RedisConfig();
        log.info(redisUtils.get("company").toString());
        return IdUtils.generator().toString();
    }
}
